<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Jialeo\LaravelSchemaExtend\Schema;

class CreateArticleUserRelation extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('article_user_relation', function (Blueprint $table) {
            $table->id();
            $table->unsignedInteger('articleId')->default(0)->comment('文章 ID');
            $table->unsignedInteger('type')->default(0)->comment('数据来源0默认 1:点赞 2:收藏 3:转发 4:阅读 5:展示');
            $table->unsignedInteger('status')->default(0)->comment('状态0取消 1:正常');

            $table->tinyInteger('isDeleted')->default(0)->comment('');
            $table->unsignedInteger('createdAt')->default(0)->comment('创建时间');
            $table->unsignedInteger('createdByUid')->default(0)->comment('创建人');
            $table->unsignedInteger('updatedAt')->default(0)->comment('修改时间');
            $table->unsignedInteger('updatedByUid')->default(0)->comment('修改人');
            $table->collation = 'utf8mb4_general_ci';
            $table->comment = '文章关联用户操作表';

            $table->index(['articleId', 'createdByUid', 'type'], 'idx_article_user_rel');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('article_user_relation');
    }
}
